package com.h2cloud.rolling;

/**
 * @author: wulongkai
 * @create: 2023-06-07 19:55
 **/

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<>();
        System.out.println("persons.isEmpty() = " + persons.isEmpty());
        Map<String, Person> personMap = persons.stream()
                .collect(Collectors.toMap(Person::getName, person -> person));

        System.out.println(personMap);
        Map<String, Person> personMap2 = new HashMap<>();
        System.out.println(personMap2);
        List<String> beforeFields = new ArrayList<>();
        String join = String.join("、", beforeFields);
        System.out.println("join = " + join);
        System.out.println("StringUtils.isEmpty(join) = " + StringUtils.isEmpty(join));
    }

    static class Person {
        private String name;
        private int age;

        public Person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public int getAge() {
            return age;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
}

